package cn.kongwg.yygh.hosp.controller;

import cn.kongwg.yygh.cmn.client.DictFeignClient;
import cn.kongwg.yygh.common.result.Result;
import cn.kongwg.yygh.hosp.service.HospitalService;
import cn.kongwg.yygh.model.hosp.Hospital;
import cn.kongwg.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.hibernate.validator.constraints.SafeHtml;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author kongwg
 * @create 2021-04-13 15:08
 */
@Api(tags = "医院管理")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;


    @ApiOperation("分页查询医院")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> hospitalList = hospitalService.selectHospPage(page, limit, hospitalQueryVo);

        return Result.ok(hospitalList);
    }

    //更新医院上线状态
    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id, @PathVariable Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    //医院详情信息
    @ApiOperation(value = "医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        Map<String,Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }
}
